package com.whut.coc.domain.service;

import com.whut.coc.domain.model.coc.factory.UserTagFactory;
import com.whut.coc.domain.model.coc.valueobject.UserTag;
import com.whut.coc.domain.repository.UserTagRepository;
import com.whut.coc.util.RedisIdWorker;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @Description: 
* @Author: Zonghe Wang
* @Date: 2025/6/22 16:35
*/
@Service
@RequiredArgsConstructor
public class UserTagDomainService {

    private final UserTagRepository userTagRepository;

    private final RedisIdWorker redisIdWorker;

    public boolean save(Long uid, String tag) {

        // 1. 构建领域对象
        UserTag userTag = UserTagFactory.createUserTag(redisIdWorker.nextId("user-tag"), uid, tag);

        // 2. 调用仓储层保存
        return userTagRepository.save(userTag);
    }

    public List<String> queryByUid(Long uid) {
        return userTagRepository.queryByUid(uid);
    }
}
